package com.wangzhenyu.learn.test.designPattern

//原型模式

@Suppress("UNUSED")
object EPrototypePattern {


    data class Sheep(val name: String, val age: Int, val color: String, val friend: Sheep?)


    //浅拷贝
    fun test() {
        val a = Sheep("GanYu", 26, "blue", null)

        val b = Sheep("QiQi", 12, "grey", a)

        val c = b.copy(name = "KeQin" )

        println(b === c)

        println(b.friend === c.friend)


    }

    //深拷贝
    fun test02() {
        val a = Sheep("GanYu", 26, "blue", null)

        val b = Sheep("QiQi", 12, "grey", a)

        val c = b.copy(name = "KeQin", friend = a.copy())

        println(b === c)

        println(b.friend === c.friend)

    }
}